package top.hjc.orange.user.domain.model;

import jakarta.persistence.*;

/**
 * @author: huangjicheng
 * @date: 2025/9/30
 * @desc：
 */
@Entity
public class UserInfo {

    @Id
    private Long id;

    //    // 通过user_id外键关联到User表
    //    @OneToOne
    //    @JoinColumn(name = "user_id", referencedColumnName = "id", unique = true)

    // 这种写法是共享主键[推荐]，user的主键 id就是 userInfo的主键 id
    @OneToOne(fetch = FetchType.LAZY)
    @MapsId // 表示id与User的id相同
    @JoinColumn(name = "id") // 外键列名也是id
    private User user;

    private String address;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
